<template>
  <div class="app-container">
    <div class="flex-box">
      <div class="item">
        <el-button icon="el-icon-circle-plus-outline" @click="addShow">添加用户</el-button>
      </div>
      <div class="item">
        <el-date-picker
          v-model="searchdate"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          :picker-options="pickerOptions"
          @change="getList"
        />
      </div>
      <div class="item">
        <el-select v-model="searchlevel" placeholder="请选择会员等级" @change="userLevelSearch">
          <el-option
            :key="0"
            label="全部等级"
            :value="0"
          />
          <el-option
            v-for="item in memberLevels"
            :key="item.id"
            :label="item.levelname_zn"
            :value="item.id"
          />
        </el-select>
      </div>
      <div class="item">
        <el-input v-model="searchcontent" placeholder="请输入用户联系方式">
          <el-button slot="append" icon="el-icon-search" @click="getList">搜索</el-button>
        </el-input>
      </div>
      <div class="item">
        <el-button :loading="excuserLoading" @click="exportData">导出用户</el-button>
      </div>
      <div class="item">
        <el-button @click="uploadShow">导入用户</el-button>
      </div>
      <div class="item">
        <span>总共有{{ total }}条数据</span>
      </div>
    </div>
    <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" class="no-r-b"
      :header-cell-style="{background:'#FAFAFA',color:'#666666'}" row-key="id">
      <el-table-column align="center" show-overflow-tooltip label="会员号" width="155">
        <template slot-scope="scope">
          <span>{{ scope.row.spreadid }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" show-overflow-tooltip label="用户邮箱" width="100">
        <template slot-scope="scope">
          <span>{{ scope.row.email }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" show-overflow-tooltip label="用户名称" width="90">
        <template slot-scope="scope">
          <span>{{ scope.row.username }}</span>
        </template>
      </el-table-column>

      <!-- <el-table-column align="center" label="中文名称" width="200">
        <template slot-scope="scope">
          <span>{{ scope.row.username_zn }}</span>
        </template>
      </el-table-column> -->

      <el-table-column align="center" label="头像" width="77">
        <template slot-scope="scope">
          <el-avatar :size="52" :src="domainName+scope.row.avator">
            <el-avatar :size="52" icon="el-icon-user-solid"></el-avatar>
          </el-avatar>
          <!-- <img :src="domainName+scope.row.avator" /> -->
        </template>
      </el-table-column>

      <el-table-column align="center" label="联系方式" width="110">
        <template slot-scope="scope">
          <span>{{ scope.row.contact }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" show-overflow-tooltip label="钱包余额" width="100">
        <template slot-scope="scope">
          <span>{{ scope.row.balance/100 }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" show-overflow-tooltip label="反馈现金余额" width="110">
        <template slot-scope="scope">
          <span>{{ scope.row.cycle_balance/100 }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" show-overflow-tooltip label="积分" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.coin }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" show-overflow-tooltip label="累计消费(元)" width="110">
        <template slot-scope="scope">
          <span>{{ scope.row.total/100 }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" show-overflow-tooltip label="用户生日" width="94">
        <template slot-scope="scope">
          <span>{{ scope.row.birthday }}</span>
        </template>
      </el-table-column>

      <el-table-column class-name="status-col" show-overflow-tooltip label="状态" width="70">
        <template slot-scope="{row}">
          <el-tag :type="row.deleted_at | statusFilter">
            {{ row.deleted_at?'已禁用':'正常' }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip label="创建时间">
        <template slot-scope="scope">
          <span>{{ scope.row.created_at | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="360">
        <template slot-scope="scope">
          <div class="caozuo">
            <span type="primary" size="small" icon="el-icon-edit" @click="editShow(scope.row)">编辑</span>
            <span type="primary" size="small" icon="el-icon-s-finance" @click="rechargeShow(scope.row)">充值</span>
            <span type="primary" size="small" icon="el-icon-s-finance" @click="withdrawShow(scope.row)">提现</span>
            <span type="primary" size="small" icon="el-icon-s-finance" @click="showGetWine(scope.row)">取酒</span>
            <span type="primary" size="small" icon="el-icon-s-finance" @click="editPwdShow(scope.row,1)">修改登录密码</span>
            <span type="primary" size="small" icon="el-icon-s-finance" @click="editPwdShow(scope.row,2)">修改支付密码</span>
            <span v-if="scope.row.deleted_at" type="success" size="small" icon="el-icon-thumb" @click="forbiden(scope.row,1)">启用</span>
            <span v-else type="danger" size="small" icon="el-icon-delete" @click="forbiden(scope.row,0)">禁用</span>
          </div>
          <!-- <el-button type="primary" size="small" icon="el-icon-edit" @click="editShow(scope.row)">编辑</el-button>
          <el-button type="primary" size="small" icon="el-icon-s-finance" @click="rechargeShow(scope.row)">充值</el-button>
          <el-button type="primary" size="small" icon="el-icon-s-finance" @click="withdrawShow(scope.row)">提现</el-button>
          <el-button type="primary" size="small" icon="el-icon-s-finance" @click="editPwdShow(scope.row,1)">修改登录密码</el-button>
          <el-button type="primary" size="small" icon="el-icon-s-finance" @click="editPwdShow(scope.row,2)">修改支付密码</el-button>
          <el-button v-if="scope.row.deleted_at" type="success" size="small" icon="el-icon-thumb" @click="forbiden(scope.row,1)">启用</el-button>
          <el-button v-else type="danger" size="small" icon="el-icon-delete" @click="forbiden(scope.row,0)">禁用</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination v-if="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" :pageSizes="[10,20,30,40,50]" @pagination="getList" />

    <!--列表数据添加/编辑开始  -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" center width="95%" class="user" @closed="closed">
      <el-form ref="ruleForm" :model="formRow" label-width="130px">
        <el-form-item v-if="dialogTitle=='用户编辑'">
          <template slot="label">
            <span style="line-height: 52px;">用户头像:</span>
          </template>
          <el-avatar :size="52" :src="domainName+formRow.avator">
            <el-avatar :size="52" icon="el-icon-user-solid"></el-avatar>
          </el-avatar>
          <!-- <el-upload
            class="avatar-uploader"
            action="#"
            :http-request="doUploadImg"
            :show-file-list="false"
          >
            <el-avatar :size="52" v-if="formRow.avator" :src="domainName+(formRow.avator)" class="avatar"></el-avatar>
            <img v-else src="../../../public/img/add_avatar.png" />
          </el-upload> -->
        </el-form-item>
        <!-- <el-form-item label="用户邮箱:">
          <el-input v-model="formRow.email" type="email" auto-complete="off" />
        </el-form-item> -->
        <el-form-item label="用户名称:">
          <el-input v-model="formRow.username" auto-complete="off" />
        </el-form-item>
        <!-- <el-form-item label="用户中文名:">
          <el-input v-model="formRow.username_zn" auto-complete="off" />
        </el-form-item> -->
        <el-form-item label="联系方式:">
          <el-input v-model="formRow.contact" auto-complete="off" />
        </el-form-item>
        <el-form-item label="累计消费总额(元):">
          <el-input v-model="moneyTotal" auto-complete="off" />
        </el-form-item>
        <el-form-item label="会员号码:" v-if="showSpreadId">
          <el-input v-model="formRow.spreadid" auto-complete="off" />
        </el-form-item>
        <el-form-item label="会员号码:" v-else>
          <span style="line-height: 36px;">{{formRow.spreadid}}</span>
        </el-form-item>
        <!-- <el-form-item label="出生日期:">
          <el-date-picker
            v-model="birthday"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"
          />
        </el-form-item> -->
        <!-- <el-form-item> -->
        <el-button @click="submitForm('ruleForm')">保存</el-button>
        <!-- </el-form-item> -->
      </el-form>
    </el-dialog>
    <!-- 列表数据添加/编辑结束 -->

    <!-- 导入数据开始 -->
    <el-dialog title="导入用户" :visible.sync="dialogUploadVisible" center class="users" width="95%">
      <el-upload
        class="upload-demo"
        drag
        name="files"
        :show-file-list="false"
        :action="domainName+'/admin/user/impuser'"
        :with-credentials="true"
        :headers="uploadHeader"
        :on-success="uploaded"
        multiple>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
      </el-upload>
      <p>
        提示：导入前请先下载导入模板，并按照导入模板格式修改后上传；
        <a :href="donwUrl">
          <el-button>下载模板</el-button>
        </a>
      </p>
    </el-dialog>
    <!-- 导入数据结束 -->

    <!-- 充值提现开始 -->
    <el-dialog :title="dialogRWTitle" :visible.sync="dialogRWVisible" center width="95%" class="users">
      <el-form ref="ruleForm" :model="formRow" label-width="80px">
        <el-form-item label="用户名称:">
          <span>{{ formRow.username }}</span>
        </el-form-item>
        <el-form-item label="充值金额:">
          <el-input type="number" v-model="RWnumber" auto-complete="off" />
        </el-form-item>
        <!-- <el-form-item> -->
          <el-button type="primary" @click="submit">确认</el-button>
        <!-- </el-form-item> -->
      </el-form>
    </el-dialog>
    <!-- 充值提现结束 -->

    <!-- 取酒开始 -->
    <el-dialog title="已存酒列表" :visible.sync="dialogWineVisible" center width="95%">
      <el-table v-loading="wineStatus" :data="wineData" border fit highlight-current-row style="width: 100%" class="no-r-b"
      :header-cell-style="{background:'#FAFAFA',color:'#666666'}" row-key="id">
      <el-table-column align="center" show-overflow-tooltip label="商品名称">
        <template slot-scope="scope">
          <span>{{ scope.row.proname_zn + '('+ scope.row.proname +')' }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip label="商品主图" width="80">
        <template slot-scope="scope">
          <el-image
              :src="domainName+scope.row.image"
              :preview-src-list="[domainName+scope.row.image]">
          </el-image>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip label="数量" width="80">
        <template slot-scope="scope">
          <span>{{scope.row.number}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip label="创建时间">
        <template slot-scope="scope">
          {{ scope.row.created_at }}
        </template>
      </el-table-column>
        <el-table-column align="center" label="操作" width="50">
          <template slot-scope="scope">
            <div class="caozuo">
              <span @click="dostoget(scope.row)">取酒</span>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <el-dialog title="取酒" :visible.sync="dialogQuVisible" center width="95%" class="users">
      <el-form :model="doStogetParams">
        <el-form-item label="商品名称">
          <span>{{doStogetParams.prodname}}</span>
        </el-form-item>
        <el-form-item label="商品主图">
          <el-image
              style="max-width: 130px;"
              :src="domainName+doStogetParams.image"
              :preview-src-list="[domainName+doStogetParams.image]">
          </el-image>
        </el-form-item>
        <el-form-item label="创建时间">
          <span>{{doStogetParams.time}}</span>
        </el-form-item>
        <el-form-item label="要取数量">
          <el-input type="number" v-model="doStogetParams.number"></el-input>
        </el-form-item>
        <el-button @click="comDoSt">确认取出</el-button>
      </el-form>
    </el-dialog>
    <!-- 取酒结束 -->

    <!-- 修改密码开始 -->
    <el-dialog :title="dialogPwdTitle == 1 ? '修改登录密码' : '修改支付密码'" :visible.sync="dialogPwdVisible" center width="95%" class="users">
      <el-form ref="ruleForm" :model="formRow" label-width="80px">
        <el-form-item label="用户名称:">
          <span>{{ formRow.username }}</span>
        </el-form-item>
        <el-form-item label="密码:">
          <el-input type="number" v-model="password" auto-complete="off" />
        </el-form-item>
        <el-form-item label="重复密码:">
          <el-input type="number" v-model="password_confirmation" auto-complete="off" />
        </el-form-item>
        <!-- <el-form-item> -->
          <el-button type="primary" @click="submitEditPwd">确认</el-button>
        <!-- </el-form-item> -->
      </el-form>
    </el-dialog>
    <!-- 修改密码结束 -->
  </div>
</template>

<script>
import { getUserList, getLevList, userAdd, userEdit, userStatus, uploadData, recharge, withdraw, editLoginPwd, editPayPwd, excuser, stores, stoget } from '@/api/member'
import { uploadImg, uploadImgs, getImgs, downfile } from '@/api/uploadImg'
import { formatJson, createUniqueString } from '@/utils/index'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import { Message } from 'element-ui'
import UploadExcelComponent from '@/components/UploadExcel/index.vue'
import imgzip from 'imgzip'
import { getToken } from '@/utils/auth'

export default {
  name: 'UserList',
  components: { Pagination, UploadExcelComponent },
  filters: {
    statusFilter(status) {
      if (status) {
        status = 'deleted'
      } else {
        status = 'published'
      }
      const statusMap = {
        published: 'success',
        draft: 'info',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: [],
      modules: [], // 弹窗下拉框数据
      total: 0,
      listLoading: true,
      excuserLoading: false,
      listQuery: {
        page: 1,
        limit: 10
      },
      memberLevels: [], // 权限类型
      searchlevel: 0, // 搜索等级
      searchcontent: '', // 搜索内容
      searchdate: '', // 搜索日期
      // 日期插件参数
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            picker.$emit('pick', [start, end])
          }
        }]
      },
      // 弹窗标题
      dialogTitle: '',
      dialogFormVisible: false,
      dialogUploadVisible: false,
      // 表单数据
      formRow: {
        avator: '',
        // email: '',
        username: '',
        contact: '',
        total: 0,
        // birthday: '1990-09-18'
      },
      number: 0,//充值金额
      dialogRWVisible: false,
      dialogRWTitle: '',
      dialogPwdVisible: false,
      dialogPwdTitle: '',
      password: null,
      password_confirmation: null,
      domainName: process.env.VUE_APP_BASE_DOMAIN,
      showSpreadId: true,
      uploadHeader: {},
      wineData: [],
      dialogWineVisible: false,
      dialogQuVisible: false,
      wineStatus: false,
      doStogetParams: {
        id: '',
        proid: '',
        number: 0
      }
    }
  },
  computed: {
    birthday: {
      get() {
        return new Date(Date.parse(this.formRow.birthday.replace(/-/g, '/')))
      },
      set(val) {
        this.formRow.birthday = val
      }
    },
    moneyTotal: {
      get() {
        return this.formRow.total / 100
      },
      set(val) {
        this.formRow.total = val * 100
      }
    },
    RWnumber: {
      get() {
        return this.number / 100
      },
      set(val) {
        this.number = val * 100
      }
    },
    donwUrl() {
      let fileUrl = encodeURIComponent(this.domainName +'/storage/excels/template.xlsx');
      return this.domainName+'/downfile?fileurl='+fileUrl+'&filename='+ encodeURIComponent('template.xlsx');
    }
  },
  created() {
    this.getList()
    this.get_levels()
  },
  methods: {
    // 获取列表数据
    getList() {
      // this.list = []
      this.listLoading = true
      const search = { searchcontent: this.searchcontent, searchlevel: this.searchlevel }
      if (this.searchdate) {
        const startDate = this.searchdate[0]
        const endDate = this.searchdate[1]
        search.startDate = startDate
        search.endDate = endDate
      }
      const postdata = { ...this.listQuery, ...search }
      getUserList(postdata).then((response) => {
        const { data } = response
        console.log(response, 'getUserList')
        this.list = data.list
        // for(let i=0;i<data.list.length;i++){
        //   this.$set(this.list,i,data.list[i])
        // }
        // this.$set(this.list)
        this.total = data.total
        this.listLoading = false
      })
    },
    // 用户等级搜索
    userLevelSearch(e) {
      this.searchlevel = e
      this.getList()
    },
    // 获取所有模块
    get_levels() {
      getLevList({ page: 1, limit: 100 }).then(response => {
        const { data } = response
        this.memberLevels = data.list
        console.log(data, 'getLevList')
      })
    },
    // 表单提交方法
    submitForm(formName) {
      if (this.formRow.id) {
        console.log(this.formRow, 'userEdit')
        userEdit(this.formRow).then(res => { // 编辑用户
          Message({
            message: '保存成功',
            type: 'success',
            duration: 2 * 1000
          })
          this.getList()
          this.dialogFormVisible = false
        })
      } else {
        userAdd(this.formRow).then(res => { // 添加用户
          Message({
            message: '保存成功',
            type: 'success',
            duration: 2 * 1000
          })
          this.getList()
          this.dialogFormVisible = false
        })
      }
    },

    // 头像图片上传
    doUploadImg(params) {
      const compress = new imgzip({ quality: 0.6 })
      const _this = this
      // 调用图片压缩
      compress.photoCompress(params.file, function(base64) {
        const blob = imgzip.convertBase64UrlToBlob(base64)
        const formData = new FormData()
        formData.append('images', blob, 'file_' + Date.parse(new Date()) + '.jpg') // 文件对象
        // 上传操作....
        uploadImg(formData).then(response => {
          _this.formRow.avator = response.data
        })
      })
    },

    // 添加
    addShow() {
      this.formRow = {
        username: '',
        contact: '',
        total: 0,
        spreadid: ''
      }
      this.showSpreadId = true
      this.dialogTitle = '用户添加'
      this.dialogFormVisible = true
    },

    // 编辑
    editShow(row) {
      console.log(row)
      this.formRow = row
      this.formRow = {
        avator: row.avator,
        id: row.id,
        username: row.username,
        contact: row.contact,
        total: row.total,
        spreadid: row.spreadid
      }
      if(row.spreadid){
        this.showSpreadId = false;
      }else{
        this.showSpreadId = true;
      }
      // delete(this.formRow['paypass'])
      this.dialogTitle = '用户编辑'
      this.dialogFormVisible = true
    },
    closed(){
      this.formRow = {
        avator: '',
        id: '',
        username: '',
        contact: '',
        total: '',
        spreadid: ''
      }
    },

    // 禁用or启用
    forbiden(row, status) {
      const word = status ? '启用' : '禁用'
      this.$confirm('确认' + word + row.username + '吗?', word + '确认', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        userStatus({ id: row.id, walletid: row.walletid, status: status }).then(res => {
          this.$message({
            type: 'success',
            message: status ? '启用成功' : '禁用成功'
          })
          this.getList()
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: status ? '已取消启用' : '已取消禁用'
        })
      })
    },
    // 改变用户状态
    changeStatus(id, status) {
      // statusAdmin({ id, status }).then(() => {
      //   const type = status ? 'success' : 'success'
      //   const message = status ? '启动成功' : '禁用成功'
      //   this.$message({ type, message })
      //   this.getList()
      // })
    },

    // 导出
    exportData() {
      this.excuserLoading = true
      const search = { searchcontent: this.searchcontent, searchlevel: this.searchlevel }
      if (this.searchdate) {
        const startDate = this.searchdate[0]
        const endDate = this.searchdate[1]
        search.startDate = startDate
        search.endDate = endDate
      }
      const postdata = { ...this.listQuery, ...search }
      excuser(postdata).then((response) => {
        const { data } = response
        console.log(response, 'getUserList')
        this.doExportData(data)
      })
    },
    doExportData(userList) {
      // console.log(userList)
      import('@/vendor/Export2Excel').then(excel => {
        const tHeader = ['会员号码', '用户邮箱', '英文名称', '中文名称', '联系方式', '累计消费', '状态', '出生日期', '注册时间']
        const filterVal = ['spreadid', 'email', 'username', 'username_zn', 'contact', 'total', 'deleted_at', 'birthday', 'created_at']
        const list = userList
        const data = formatJson(filterVal, list)
        const filename = createUniqueString()
        console.log(data, 'exportData')
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename,
          autoWidth: true,
          bookType: 'xlsx'
        })
        this.excuserLoading = false
      })
    },
    formatJson(filterVal) {
      return this.allBillList.map(v => filterVal.map(j => {
        if (j === 'deleted_at') {
    			return v[j] ? '禁用':'正常'
        } else {
    			return v[j]
        }
      }))
    },

    // 导入
    uploadShow() {
      this.uploadHeader = {
        'X-Token': getToken()
      }
      this.dialogUploadVisible = true
    },
    uploaded(e) {
      // console.log(e)
      if(e.code==0){
        this.$message({
          message: '导入成功',
          type: 'success'
        })
      }else{
        this.$message({
          message: e.message,
          type: 'error'
        })
      }
      this.getList()
      this.dialogUploadVisible = false
    },
    //下载模板
    uploadFlie() {
      downfile({fileurl: this.domainName+'/storage/excels/template.xlxs',filename: 'template.xlsx'})
    },
    reimport() {
      console.log(this.importfailedList)
    },
    //充值
    rechargeShow(row) {
      this.number = 0
      this.formRow = row
      this.dialogRWTitle = '充值'
      this.dialogRWVisible = true
    },
    //提现
    withdrawShow(row) {
      this.number = 0
      this.formRow = row
      this.dialogRWTitle = '提现'
      this.dialogRWVisible = true
    },
    //提交 充值 or 提现
    submit() {
      if(this.dialogRWTitle == '充值'){
        if(this.number>0){
          recharge({id:this.formRow.id,number: Number(this.number)}).then(res=>{
            this.$message({
              type: 'success',
              message: '充值成功'
            })
            this.dialogRWVisible = false
          })
        }else{
          this.$message({
            type: 'warning',
            message: '充值金额不能小于零'
          })
        }
      }else if(this.dialogRWTitle == '提现'){
        if(this.number>0){
          withdraw({id:this.formRow.id,number: Number(this.number)}).then(res=>{
            this.$message({
              type: 'success',
              message: '提现成功'
            })
            this.dialogRWVisible = false
          })
        }else{
          this.$message({
            type: 'warning',
            message: '提现金额不能小于零'
          })
        }
      }
    },
    //取酒
    showGetWine(row) {
      this.wineData = []
      this.dialogWineVisible = true
      this.wineStatus = true
      stores({id:row.id}).then(res=>{
        console.log(res)
        this.wineData = res.data
        this.wineStatus = false
      })
    },
    dostoget(row) {
      this.doStogetParams = {
        id: row.uid,
        proid: row.proid,
        prodname: row.proname_zn + '(' + row.proname + ')',
        image: row.image,
        time: row.created_at
      }
      this.dialogQuVisible = true
    },
    comDoSt(){
      console.log(this.doStogetParams)
      let submitData = {
        id: this.doStogetParams.id,
        proid: this.doStogetParams.proid,
        number: this.doStogetParams.number
      }
      stoget(submitData).then(res=>{
        this.$message({
          message: '取酒成功',
          type: 'success'
        })
        this.dialogQuVisible = false
        this.showGetWine(submitData)
      })
    },
    //修改 登录 or 支付 密码
    editPwdShow(row,type) {
      this.formRow = row
      this.dialogPwdVisible = true
      this.dialogPwdTitle = type
    },
    submitEditPwd() {
      if(this.dialogPwdTitle == 1){
        editLoginPwd({id: this.formRow.id, password: this.password, password_confirmation: this.password_confirmation}).then(res=>{
          if(res.code == 0){
            this.$message({
              type: 'success',
              message: '修改登录密码成功'
            })
            this.dialogPwdVisible = false
          }
        })
      }else if(this.dialogPwdTitle == 2){
        editPayPwd({id: this.formRow.id, password: this.password, password_confirmation: this.password_confirmation}).then(res=>{
          if(res.code == 0){
            this.$message({
              type: 'success',
              message: '修改支付密码成功'
            })
            this.dialogPwdVisible = false
          }
        })
      }
    }
  }
}
</script>

<style scoped>
.edit-input {
  padding-right: 100px;
}
.cancel-btn {
  position: absolute;
  right: 15px;
  top: 10px;
}
</style>
